//
//  HMuserInfoView.m
//  G05爱鲜蜂
//
//  Created by 小灰灰 on 16/10/15.
//  Copyright © 2016年 何源. All rights reserved.
//

#import "HMuserInfoView.h"

@implementation HMuserInfoView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}
-(void)setupUI{
    //ava 背景图片
    UIImageView *avaBcImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_my_avatar_bg"]];
    [self  addSubview:avaBcImage];
    [avaBcImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    //用户头像
    UIImageView *iconImage =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_my_avatar"]];
    [self addSubview:iconImage];
    [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(30);
        make.centerX.equalTo(self);
    }];
    //用户名
    UILabel *nameLabel =[[UILabel alloc] init];
    nameLabel.text = @"0123456789";
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.textColor = [UIColor whiteColor];
    nameLabel.font = [UIFont systemFontOfSize:16];
    [nameLabel sizeToFit];
    [self addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconImage.mas_bottom).offset(10);
        make.centerX.equalTo(iconImage);
    }];
 
    //设置按钮
    UIButton *btn =[[UIButton alloc] init];
    [btn setImage:[UIImage imageNamed:@"v2_my_settings_icon"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"v2_my_settings_icon"] forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self  addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self ).offset(15);
        make.trailing.equalTo(self).offset(-5);
        make.width.height.equalTo(@40);
    }];

}
//设置按钮点击
-(void)rightBtnClick
{
   if(self.settingBtnClick)
   {
       self.settingBtnClick();
   }
}



@end
